/+
Library dbapi - Simple database api for the D programming language.

Copyright (C) 2007 Myron Alexander (myron.alexander...gmail.com)

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+/

/+
This module exists to get around a circular dependency between connection others.
+/

module dbapi.internal.sqlite3.internalconnection;

private import dbapi.internal.sqlite3.definitions;

private import sqlite.sqlite3;

/**
 * Interface for handler classes that handle transaction events.
 *
 * The connection level events are implicit and handled when the class is
 * instantiated and destroyed.
 */
interface TransactionModeHandler {
   /**
    * Invoked when the statement is created to ensure that the statement type
    * is valid for the transaction mode.
    */
   void validateStatementType (StatementType statementType);

   // Batch execution events
   void startBatch ();
   void batchError ();
   void endBatch ();

   // Non-Batch execution events
   void startExecute (StatementType statementType);
   void executionError ();
   void endExecute ();

   // A database operation was aborted. Transaction may have been terminated.
   void onAbort ();

   // Explicit termination of transaction events
   bool commit ();
   void rollback ();

   // Transaction state
   bool inTransaction ();

   // Called when the connection is closed. Causes a rollback.
   void onClose ();

   // Returns the transaction mode associated with the handler.
   TransactionMode transactionMode ();

   // Returns the transaction type associated with the handler.
   TransactionType transactionType ();
}

public interface InternalConnection {
   string                  dsn ();
   bool                    isOpen ();
   TransactionModeHandler  transModeHandler ();
   sqlite3*                dbcon ();
}

